<?php
/**
 * Created by PhpStorm.
 * User: lenovo
 * Date: 2020/5/25
 * Time: 11:47
 */
namespace App\HttpController;

use EasySwoole\Http\AbstractInterface\AbstractRouter;
use FastRoute\RouteCollector;
use EasySwoole\Http\Request;
use EasySwoole\Http\Response;

class Router extends AbstractRouter
{
    function initialize(RouteCollector $routeCollector)
    {
       $this->setGlobalMode(false);
        $routeCollector->addRoute(['GET'], '/Test/Test', '/Test/Test');#测试
       #登录与后台人员管理
        $routeCollector->addRoute(['POST'], '/admin/login', '/Admin/Admin/Login');#登录
        $routeCollector->addRoute(['POST'], '/admin/admin', '/Admin/Admin/AddAdmin');#添加管理员
        $routeCollector->addRoute(['GET'], '/admin/admin', '/Admin/Admin/list');#管理员列表
        $routeCollector->addRoute(['PUT'], '/admin/admin', '/Admin/Admin/updateAdmin');#修改管理员
        $routeCollector->addRoute(['DELETE'], '/admin/admin', '/Admin/Admin/deleteAdmin');#删除管理员

        #应用管理
        $routeCollector->addRoute(['GET'], '/admin/app', '/Admin/App/list');#应用列表
        $routeCollector->addRoute(['POST'], '/admin/app', '/Admin/App/createApp');#添加应用
        $routeCollector->addRoute(['PUT'], '/admin/app', '/Admin/App/updateApp');#修改应用
        $routeCollector->addRoute(['DELETE'], '/admin/app', '/Admin/App/deleteApp');#删除应用


        #角色管理
        $routeCollector->addRoute(['GET'], '/admin/adminGroup', '/Admin/AdminGroup/list');#角色列表
        $routeCollector->addRoute(['POST'], '/admin/adminGroup', '/Admin/AdminGroup/createGroup');#添加角色
        $routeCollector->addRoute(['PUT'], '/admin/adminGroup', '/Admin/AdminGroup/updateGroup');#修改角色
        $routeCollector->addRoute(['DELETE'], '/admin/adminGroup', '/Admin/AdminGroup/deleteGroup');#删除角色

        #客服管理
        $routeCollector->addRoute(['GET'], '/admin/supportPerson', '/Admin/SupportPerson/lists');#客服列表
        $routeCollector->addRoute(['POST'], '/admin/supportPerson', '/Admin/SupportPerson/createSupportPerson');#创建客服
        $routeCollector->addRoute(['PUT'], '/admin/supportPerson', '/Admin/SupportPerson/editSupportPerson');#修改客服

        #客服后台
        $routeCollector->addRoute(['POST'], '/supportPerson/login', '/SupportPerson/SupportPerson/login');#客服登录后台
        $routeCollector->addRoute('POST', '/Qiniucallback', '/File/Qiniucallback');#七牛回调
        #路由管理
        $this->setMethodNotAllowCallBack(function (Request $request,Response $response){
            $response->write('未找到处理方法');
            return false;//结束此次响应
        });

        $this->setRouterNotFoundCallBack(function (Request $request,Response $response){
            $response->write('未找到路由匹配1');
            return false;//结束此次响应
        });
    }
}